package com.chenye.swagger2.ApiController;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @Auther:chenye
 * @Data:2018/4/11
 * @Description:
 */
@RestController
@RequestMapping("user")
public class UserController {
    static Map<String, String> users = Collections.synchronizedMap(new HashMap<String, String>());

//    @ApiOperation(value="获取用户列表", notes="测试示例",tags = "private")
    @RequestMapping(value={""}, method=RequestMethod.GET)
    public List<String> getUserList() {
        List<String> r = new ArrayList<String>(users.values());
        return r;
    }

//    @ApiOperation(value="创建用户", notes="根据User对象创建用户",tags = "company")
//    @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "String")
    @RequestMapping(value="", method=RequestMethod.POST)
    public String postUser(String user) {
        users.put(user, user);
        return "success";
    }

    @RequestMapping("test")
    public String test(){
        return "test";
    }


}
